import type { IColumnsOption } from 'vc';
import { INDEX, COMPANY_NAME, BUSINESS_DATA, REGISTERED_CAPITAL, PROVINCE, CITY, COUNTRY, INDUSTRY_CATEGORY } from '@/utils/tableColumn';
import {setHrefUrlTool} from "@/utils";

export function useTable() {
  const columns = ref<IColumnsOption[]>([
    { ...INDEX },
    { ...COMPANY_NAME },
    {
      field: 'noticeDate',
      title: '披露日期',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 110,
      sortBy: 'noticeDate'
    },
    {
      width: 160,
      field: 'attachments',
      title: '信息来源',
      slots: {
        default: ({ row }) => {
          return (
            <div>
              <a onClick={() => setHrefUrlTool(row.fileType, row.fileUrl)}>
                查看
              </a>
              <br />
            </div>
          );
        }
      }
    },
    {
      field: 'statisticalYear',
      title: '补贴年度',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 110,
      sortBy: 'statisticalYear'
    },
    {
      field: 'liabilityLimit',
      title: '保险金额',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 200,
      sortBy: 'liabilityLimit'
    },
    {
      field: 'premium',
      title: '保费金额',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 200,
      sortBy: 'premium'
    },
    {
      field: 'subsidyPlan',
      title: '拟补贴金额',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 200,
      sortBy: 'subsidyPlan'
    },
    {
      field: 'subsidyDeduct',
      title: '考核扣除',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 200,
      sortBy: 'subsidyDeduct'
    },
    {
      field: 'subsidyActual',
      title: '实补贴金额',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 110,
      sortBy: 'subsidyActual'
    },
    {
      field: 'startDate',
      title: '起保日期',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 110,
      sortBy: 'startDate'
    },
    {
      field: 'endDate',
      title: '终保日期',
      align: 'center',
      // sort: 'desc',
      sortable: true,
      width: 110,
      sortBy: 'endDate'
    },
    {
      field: 'riskLevel',
      title: '突发环境预案风险等级',
      align: 'center',
      // sort: 'desc',
      width: 200,
    },
    { ...PROVINCE },
    { ...CITY },
    { ...INDUSTRY_CATEGORY },
    { ...BUSINESS_DATA },
    { ...REGISTERED_CAPITAL }
  ]);

  // 变更弹窗
  const showPermitChangesDetail = ref(false);
  const permitChangesDetails = ref([]);

  const permitChangesDetailFn = (data) => {
    console.log(data);
    showPermitChangesDetail.value = true;
    permitChangesDetails.value = data;
  };

  return {
    columns
  };
}
